﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Controls.Primitives;


namespace SharpMap.Wpf
{
    public class ContentLayerView : ItemsControl, SharpMap.Layers.ILayer
    {
        static ContentLayerView()
        {
            DefaultStyleKeyProperty.OverrideMetadata(typeof(ContentLayerView), new FrameworkPropertyMetadata(typeof(ContentLayerView)));
        }


        protected override bool IsItemItsOwnContainerOverride(object item)
        {
            return item.GetType() == typeof(ContentControl);
        }
        protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
        {
            base.PrepareContainerForItemOverride(element, item);
            //UIElement uiElement = item as UIElement;
            //if(uiElement != null)
            //{
            //    ContentLayerPanel.SetWorldX(uiElement,ContentLayerPanel.GetWorldX(uiElement));
            //    ContentLayerPanel.SetWorldY(uiElement,ContentLayerPanel.GetWorldY(uiElement));
            //}
        }

        protected override DependencyObject GetContainerForItemOverride()
        {
            return new ContentLayerItem();
        }

        protected override Size MeasureOverride(Size constraint)
        {
            return base.MeasureOverride(constraint);
        }

        protected override Size ArrangeOverride(Size arrangeBounds)
        {
            return base.ArrangeOverride(arrangeBounds);
        }

        protected override void OnItemsPanelChanged(ItemsPanelTemplate oldItemsPanel, ItemsPanelTemplate newItemsPanel)
        {
            base.OnItemsPanelChanged(oldItemsPanel, newItemsPanel);
        }


        #region ILayer Members

        bool SharpMap.Layers.ILayer.AsyncQuery
        {
            get
            {
                return false;
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        SharpMap.CoordinateSystems.ICoordinateSystem SharpMap.Layers.ILayer.CoordinateSystem
        {
            get { return SharpMap.CoordinateSystems.GeographicCoordinateSystem.WGS84; }
        }

        SharpMap.CoordinateSystems.Transformations.ICoordinateTransformation SharpMap.Layers.ILayer.CoordinateTransformation
        {
            get
            {
                return null;
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        SharpMap.Data.ILayerProvider SharpMap.Layers.ILayer.DataSource
        {
            get { return null; }
        }

        bool SharpMap.Layers.ILayer.Enabled
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        SharpMap.Geometries.BoundingBox SharpMap.Layers.ILayer.Extents
        {
            get { throw new NotImplementedException(); }
        }

        string SharpMap.Layers.ILayer.LayerName
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        int? SharpMap.Layers.ILayer.Srid
        {
            get { return null; }
        }
        SharpMap.Styles.IStyle _style;
        SharpMap.Styles.IStyle SharpMap.Layers.ILayer.Style
        {
            get
            {
               return null;
            }
            set
            {
                _style = value;
            }
        }

        bool SharpMap.Layers.ILayer.IsVisibleWhen(Predicate<SharpMap.Layers.ILayer> condition)
        {
            return true;
        }

        #endregion

        #region INotifyPropertyChanged Members
        public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
        #endregion

  
 

        #region IDisposable Members

        public void Dispose()
        {
           
        }

        #endregion
    }
}
